load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "sessiondatapb",
    srcs = [
        "local_only_session_data.go",
        "sequence_cache.go",
        "sequence_cache_node.go",
        "session_data.go",
    ],
    embed = [":sessiondatapb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/security/username",
        "//pkg/sql/sem/catid",
        "//pkg/sql/types",
        "//pkg/util/admission/admissionpb",
        "//pkg/util/syncutil",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_lib_pq//oid",  # keep
    ],
)

proto_library(
    name = "sessiondatapb_proto",
    srcs = [
        "local_only_session_data.proto",
        "session_data.proto",
        "session_migration.proto",
        "session_revival_token.proto",
    ],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/sql/lex:lex_proto",
        "//pkg/util/duration:duration_proto",
        "//pkg/util/timeutil/pgdate:pgdate_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
        "@com_google_protobuf//:duration_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

go_proto_library(
    name = "sessiondatapb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/sessiondatapb",
    proto = ":sessiondatapb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/sql/lex",
        "//pkg/util/duration",
        "//pkg/util/timeutil/pgdate",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_test(
    name = "sessiondatapb_test",
    srcs = ["session_data_test.go"],
    embed = [":sessiondatapb"],
    deps = [
        "//pkg/sql/protoreflect",
        "@com_github_stretchr_testify//require",
    ],
)
